// 用户相关的api接口

import request from '@/utils/request.js'
import axios from 'axios'

export const loginAPI = data => {
  return request.post('/v1_0/authorizations', data)
}

// 获取用户信息的接口
export const getUserInfoAPI = () => {
  return request.get('/v1_0/user')
}
// 获取用户详情的接口
export const getUserProfile = () => {
  return request.get('/v1_0/user/profile')
}
// 修改用户信息详情
export const editUserProfileAPI = (obj) => {
  return request.patch('/v1_0/user/profile', obj)
}
// 上传头像
export const updateAvatarAPI = (fd) => {
  return request.patch('/v1_0/user/photo', fd)
}
// 换取token
export const exchangeTokenAPI = (refreshToken) => {
  return axios({
    url: 'http://toutiao-app.itheima.net/v1_0/authorizations',
    method: 'put',
    headers: {
      Authorization: `Bearer ${refreshToken}`
    }
  })
}
